package com.atguigu.Controller;

import cn.hutool.core.lang.copier.SrcToDestCopier;
import cn.hutool.core.util.IdUtil;
import com.atguigu.Annoton.myannotion;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@Slf4j
public class mycontroller {

    @GetMapping("controller/m1")
    public String m1(){
        String result = "";
        long startTime = System.currentTimeMillis();
        System.out.println("------方法前，come in");

        result=IdUtil.randomUUID();
        System.out.println("主业务流程订单编号："+result);

        try {
            TimeUnit.MILLISECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("---------方法后 leave out");


        long endTime = System.currentTimeMillis();

        System.out.println("-------costTime: "+(endTime-startTime)+"毫秒");

        return result;
    }

    @GetMapping("controller/m2")
    @myannotion(value = "java0923 yyds",enable = true)
    public String m2(){
        String result ="";

        result=IdUtil.randomUUID();
        System.out.println("主流程业务编号："+result);

        try {
            TimeUnit.MILLISECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return result;
    }

    @GetMapping("controller/m3")
    @myannotion(value = "m3++", enable = false)
    public String m3(){
        String result = "";

        result=IdUtil.randomUUID();
        System.out.println("主流程业务编号："+result);

        try {
            TimeUnit.MILLISECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return result;
    }
}
